/**
 * 书籍分类配置
 * 与后端 BookCategoryEnum 保持一致
 */
const BOOK_CATEGORIES = [
  { label: '历史', value: 1, selected: false },
  { label: '文学', value: 2, selected: false },
  { label: '科技', value: 3, selected: false },
  { label: '艺术', value: 4, selected: false },
  { label: '哲学', value: 5, selected: false },
  { label: '小说', value: 6, selected: false },
  { label: '传记', value: 7, selected: false },
  { label: '教育', value: 8, selected: false },
  { label: '其他', value: 9, selected: false }
];

/**
 * 根据value获取label
 */
function getCategoryLabel(value) {
  const category = BOOK_CATEGORIES.find(item => item.value === value);
  return category ? category.label : '其他';
}

/**
 * 根据label获取value
 */
function getCategoryValue(label) {
  const category = BOOK_CATEGORIES.find(item => item.label === label);
  return category ? category.value : 9;
}

module.exports = {
  BOOK_CATEGORIES,
  getCategoryLabel,
  getCategoryValue
};
